/**
* @file lcd_dev_ST7789P3_mcu8_001.h
* @brief HD24151C22 init 
* @details 
* @author huangbin
* @version V1.0.0
* @date 2025-04-25
* @copyright All documents are copyrighted by Shenzhen Xinlongwei Technology Co., LTD.
*            They may not be used for commercial purposes without permission
*/
/*******************************************************************************
HD24151C22: ST7789P3,320x240
********************************************************************************/  
#include "inc.h"
#include "drv_lcd.h"

#define SCREEN_DIR_HOR   //水平方向
static void lcdControlerInit(DRVLCD *pLcd);
void HD24151C22_fsmc_mcu_001_init(DRVLCD *pLcd)
{
#ifdef SCREEN_DIR_HOR    
	pLcd->x				= 320; //横屏
	pLcd->y				= 240;
#else
	pLcd->x				= 240;
	pLcd->y				= 320;
#endif    
	Lcd_RegInterface_FsmcMcu8_16(pLcd,0,0);
	pLcd->Reset();
	lcdControlerInit(pLcd);
}
#define St7789Write_Cmd(reg)	pLcd->WriteIndexReg(reg)
#define St7789Write_Data(dat)	pLcd->WriteRegParameter(dat)
#define DelayMs(x) LCD_Delay(x)
static void lcdControlerInit(DRVLCD *pLcd)
{
St7789Write_Cmd( 0x11);     

DelayMs(10);       

St7789Write_Cmd( 0x36);    
#ifdef SCREEN_DIR_HOR    
    St7789Write_Data( B10100000);   //横屏
#else
    St7789Write_Data( B00000000);   //竖屏
#endif     

St7789Write_Cmd( 0x3A);     
St7789Write_Data( 0x55);   

St7789Write_Cmd( 0xB2);     
St7789Write_Data( 0x0C);   
St7789Write_Data( 0x0C);   
St7789Write_Data( 0x00);   
St7789Write_Data( 0x33);   
St7789Write_Data( 0x33);   

St7789Write_Cmd( 0xB7);     
St7789Write_Data( 0x75);   //VGH=14.97V,VGL=-7.67V

St7789Write_Cmd( 0xBB);     
St7789Write_Data( 0x18);   

St7789Write_Cmd( 0xC0);     
St7789Write_Data( 0x2C);   

St7789Write_Cmd( 0xC2);     
St7789Write_Data( 0x01);   

St7789Write_Cmd( 0xC3);     
St7789Write_Data( 0x13);   

St7789Write_Cmd( 0xC4);     
St7789Write_Data( 0x20);   

St7789Write_Cmd( 0xC6);     
St7789Write_Data( 0x0F);   

St7789Write_Cmd( 0xD0);     
St7789Write_Data( 0xA4);   
St7789Write_Data( 0xA1);   

St7789Write_Cmd( 0xD6);     
St7789Write_Data( 0xA1);   

St7789Write_Cmd( 0xE0);     
St7789Write_Data( 0xD0);
St7789Write_Data( 0x0A);
St7789Write_Data( 0x11);
St7789Write_Data( 0x0D);
St7789Write_Data( 0x0C);
St7789Write_Data( 0x08);
St7789Write_Data( 0x33);
St7789Write_Data( 0x54);
St7789Write_Data( 0x48);
St7789Write_Data( 0x3B);
St7789Write_Data( 0x15);
St7789Write_Data( 0x15);
St7789Write_Data( 0x27);
St7789Write_Data( 0x2C);

St7789Write_Cmd( 0xE1);     
St7789Write_Data( 0xD0);
St7789Write_Data( 0x08);
St7789Write_Data( 0x0D);
St7789Write_Data( 0x06);
St7789Write_Data( 0x06);
St7789Write_Data( 0x13);
St7789Write_Data( 0x32);
St7789Write_Data( 0x44);
St7789Write_Data( 0x47);
St7789Write_Data( 0x37);
St7789Write_Data( 0x11);
St7789Write_Data( 0x11);
St7789Write_Data( 0x24);
St7789Write_Data( 0x2A);

St7789Write_Cmd( 0x21);     

St7789Write_Cmd( 0x29);  
//pLcd->SetWindow(0,0,320,240);
//St7789Write_Cmd( 0x2C);
//pLcd->WriteColor(0xFF0000,320*80);
////DelayMs(500);
//pLcd->WriteColor(0x00FF00,320*80);
////DelayMs(500);
//pLcd->WriteColor(0x0000FF,320*80);
//while(1);    
}
/************************END OF FILE*************************************/


